Convert the linear interval 1D data to the log interval 1D data


In [1]:
%load_ext autoreload
%autoreload 2

import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import pylab
import chopstacks as cs

In [2]:
%matplotlib inline

In [3]:
#original data
nwav=1000
ws=400.0
we=1000.0
wav=np.linspace(ws,we,nwav)
wavw=cs.buildwall(wav)
f=np.random.normal(0.0,1.0,nwav)+(np.linspace(1.0,4.0,nwav))**2.0

In [6]:
# logarithm resampling with R=100
R=100.0
hx, hxw, hf=cs.setanalogbin(wav,wavw,f,R,0)


Reset master data (hf) to zero.

In [7]:
#checl preservation
cs.check_preservation(wavw,f,hxw,hf)


(1 - sum input/sum output) = -1.11022302463e-15

In [8]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(wav,f,color="blue")
ax.plot(hx,hf,"o",color="red")
plt.xlabel("$x$")
plt.ylabel("$f$ (blue), $\hat{f}$ (red)")
plt.show()



In [9]:
#oversampling 
R=10000.0
hx, hxw, hf=cs.setanalogbin(wav,wavw,f,R,0)
cs.check_preservation(wavw,f,hxw,hf)


Reset master data (hf) to zero.
(1 - sum input/sum output) = -1.11022302463e-15

In [10]:
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(wav,f,color="blue")
ax.plot(hx,hf,"o",color="red")
plt.xlabel("$x$")
plt.ylabel("$f$ (blue), $\hat{f}$ (red)")
plt.show()

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(wav,f,color="blue")
ax.plot(hx,hf,"o",color="red")
pylab.xlim(540,550)
pylab.ylim(0,6)
plt.xlabel("$x$")
plt.ylabel("$f$ (blue), $\hat{f}$ (red)")
plt.show()



In [ ]: